import { ApiHideProperty, ApiProperty } from '@nestjs/swagger'
import { IsBoolean, IsNumber, IsOptional, IsString, Max } from 'class-validator'
import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'

/** 奖品表 */
@Entity('wheel_prize')
export class WheelPrize {
  /**
   * 奖品 ID
   */
  @PrimaryGeneratedColumn()
  @IsNumber()
  wheelPrizeId: number

  /**
   * 奖品名称
   */
  @Column()
  @IsString()
  prizeName: string

  /**
   * 奖品图片
   */
  @Column({ nullable: true })
  @IsString()
  @IsOptional()
  prizeImage?: string

  /**
   * 奖品描述
   */
  @Column({ nullable: true })
  @IsString()
  @IsOptional()
  prizeDescription?: string

  /**
   * 排序
   */
  @ApiProperty({ default: 0 })
  @Column({ default: 0 })
  @IsOptional()
  sort?: number

  /**
   * 是否启用
   */
  @ApiProperty({ default: true })
  @Column({ default: true })
  @IsBoolean()
  @IsOptional()
  isEnabled?: boolean

  /**
   * 中奖概率（%））
   */
  @ApiProperty({ default: 0 })
  @Column({ type: 'float', default: 0 })
  @IsOptional()
  @IsNumber()
  @Max(100)
  probability?: number

  /**
   * 库存
   */
  @Column({ nullable: true })
  @IsNumber()
  remaining: number

  /**
   * 是否删除
   */
  @ApiHideProperty()
  @Column({ default: false, select: false })
  isDeleted?: boolean

  @CreateDateColumn()
  createdAt?: Date

  @UpdateDateColumn()
  updatedAt?: Date
}
